﻿using System.Data;
using DbVisualizer.DbReader;
using Microsoft.VisualStudio.DebuggerVisualizers;

[assembly: System.Diagnostics.DebuggerVisualizer(
    typeof(DataReaderVisualizer), 
    typeof(DataReaderObjectSource), 
    Target = typeof(System.Data.Common.DbDataReader), 
    Description = "View DataReader")]

namespace DbVisualizer.DbReader
{
    public class DataReaderVisualizer : DialogDebuggerVisualizer, IDataTableProxy
    {
        private IVisualizerObjectProvider visualizerObjectProvider;
        
        protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            visualizerObjectProvider = objectProvider;
            var ui = new DataReaderViewer(this);

            windowService.ShowDialog(ui);
        }

        public DataTable Get()
        {
            return (DataTable)visualizerObjectProvider.GetObject();
        }
    }
}
